/**
 * @param {number} memory1
 * @param {number} memory2
 * @return {number[]}
 */
 var memLeak = function(memory1, memory2) {
    const a = [memory1,memory2]
    let i = 1
    while(a[0] >= i || a[1] >= i){
        if(a[0] >= a[1])
            a[0] -= i
        else
            a[1] -= i
        i++
    }
    return [i, ...a]
};